#!/usr/bin/perl -Tw
# $Id: location-description 100 2006-10-12 17:21:41Z cmauch $
#
# Description: Mutt Location Generator
#
# Copyright (C) 2003,2004,2005,2006 Charles Mauch <cmauch@gmail.com>
#           (C) 2001 Donald B. Marti Jr. <dmarti@zgp.org>
#
# Verbatim copying, distribution, and display of this program is permitted in
# any medium, provided this notice is preserved. Alternatively, you may create
# derivative works of any sort for any purpose, provided your versions contain no
# attribution to me, and that you assert your own authorship (and not mine) in
# every practical medium.

# to use this script from mutt, put this in .muttrc
# my_hdr X-Message-Flag: `message-flag`

use strict;

BEGIN: {
    my $random;
    open( RANDOM, "/dev/urandom" )
      or die "Can't open /dev/random for reading: $! ";
    read( RANDOM, $random, 4 );
    close RANDOM;
    srand( unpack( 'L', $random ) );
} ## end BEGIN:

print random_words( 1, locationdesc() ), "\n";

sub locationdesc {
    (  'a Wasteland of Burning Tires',
       'hometown of Lee Boyd Malvo',
       'only 2,668 cars stolen last year',
       'we have more than 1000 dams',
       'we made the worlds first nukes',
       'the Ass End of the Galaxy',
       'home of the future Tacoma Spire',
       'now featuring Exploding Volcanos',
       'Earth, Sol, Milky Way, Verse'
    );
} ## end sub locationdesc

sub random_words {
    my ( $count, @words ) = @_;
    my %rank = map { $_ => rand() } @words;
  return join( ', ', ( sort { $rank{ $a } <=> $rank{ $b } } @words )[ 0 .. rand $count ] );
}

